﻿var oMoney = null;
var oInterestRate = null;
var oPublisherRate = null;
var oTuandaiRate = null;
var oDeadline = null;
var oRepaymentType=null
$(function () {
    //限制输入数字
    limitInt($("#jiek_Share"));
    
    oInterestRate = $("#span_InterestRate").attr("attrid");
    oPublisherRate = $("#td_Rate").attr("attr_PublisherRate");
    oTuandaiRate = $("#td_Rate").attr("attr_TuandaiRate");
    oDeadline = $("#span_Deadline").attr("attrid");
    oRepaymentType = $("#td_RepaymentType").attr("attrid");
    //格式化输入份数
    $("#jiek_Share").blur(function () {
        if ($.trim($(this).val()).replace("份", "").replace(" ", "") == "0" || $.trim($(this).val()).replace("份", "").replace(" ", "") == "") {
            $(this).val("1 份");
        }
        else if (parseInt($.trim($(this).val()).replace("份", "").replace(" ", "")) > parseInt($(this).attr("maxShare"))) {
            $(this).val($(this).attr("maxShare") + " 份");
        }
        else {
            $(this).val($.trim($(this).val()).replace("份", "").replace(" ", "") + " 份");
        }
    });
    //减去
    $("#jiek_minus").click(function () {
        var obj = $("#jiek_Share");
        var currentShare = $(obj).val().replace("份", "").replace(" ", "");
        if (currentShare > 1) {
            $(obj).val((parseInt(currentShare) - 1) + " 份");
        }
    });
    //增加
    $("#jiek_plus").click(function () {
        var obj = $("#jiek_Share");
        var currentShare = $(obj).val().replace("份", "").replace(" ", "");
        if (currentShare != $(obj).attr("maxShare")) {
            $(obj).val((parseInt(currentShare) + 1) + " 份");
        }
    });
    $("#btntools").click(function () {
        oMoney = $("#jiek_Share").val().replace("份", "").replace(" ", "") * $("#td_LowerUnit").attr("attrid");
        window.open("/View/tuandaitool_1_10.html", "_blank");
    });
    //申购按钮事件
    $("#btnSubscribe").click(function () {
        var id = $(this).attr("attrid");
        var tendValue = $("#jiek_Share").val().replace("份", "").replace(" ", "");
        var title = $("#projecttitle").attr("protitle");
        if (!isCookieLogin()) {
            art.dialog({
                width: 300,
                content: '您未登录，请先登录。',
                okVal: '马上登录',
                ok: function () {
                    window.location.href = "/View/login.aspx?ReturnUrl=" + window.location.href;
                }
            });
        }
        else {
            shengou(id, tendValue, title);
        }
    });

})
